//封装请求函数
//导入 request 请求函数
import { request } from "@/utils/http";
import { AddHospitalSetParams, GetHospitalSetParams, HospitalSetItem, HospitalSetResponse, UpdateHospitalSetParams } from "./types";
import { Key } from "react";

export function reqGetHospitalSet(options: GetHospitalSetParams){
  //解构赋值
  let {page, pageSize, hosname, hoscode} = options;
  //发送请求
  return request.get<any, HospitalSetResponse>(`/admin/hosp/hospitalSet/${page}/${pageSize}`, {
    params: {
      hosname,
      hoscode
    }
  });
}

/**
 * 新增医院设置
 */
export function addHospitalSet(data: AddHospitalSetParams){
  return request.post<any, null>('/admin/hosp/hospitalSet/save', data);
}

/**
 * 获取单个医院设置信息
 */
export function getHospitalSetById(id: string){
  return request.get<any, HospitalSetItem>(`/admin/hosp/hospitalSet/get/${id}`);
}

/**
 * 更新医院设置的信息
 */
export function updateHospitalSet(data: UpdateHospitalSetParams){
  return request.put<any, null>('/admin/hosp/hospitalSet/update', data)
}

/**
 * 根据id删除某个医院设置信息
 * @param id  医院的编号
 * @returns  Promise<null>
 */
export function removeHospitalSet(id: Key){
  return request.delete<any, null>(`/admin/hosp/hospitalSet/remove/${id}`);
}

/**
 * 根据 id 列表删除医院设置信息
 * @param idList ID 数组
 * @returns 
 */
export function batchRemoveHospital(idList: Key[]){
  return request.delete<any, null>('/admin/hosp/hospitalSet/batchRemove', {
    data: idList
  });
}
